import { PAY_WAY } from "../utils/constants";
import { WxJSAPIPayment, WxH5Payment } from "./wx-pay";
import { AliPayment, AliPayCommand } from "./ali-pay";
import { VirtualPayment } from "./virtual-pay";
import { KSMiniProgramPayment } from "./ks-mp-pay";
import { MiniProgramPayment } from "./mp-blank-pay";
import { H5BlankPayment } from "./h5-blank-pay";
import { ScanPayment } from "./scan-pay";

const PAYMENT_MAP = {
  [PAY_WAY.WxJSAPIPay]: WxJSAPIPayment, //微信内api支付
  [PAY_WAY.WxH5Pay]: WxH5Payment, //跳微信app支付
  [PAY_WAY.AliPay]: AliPayment, //支付宝支付
  [PAY_WAY.AliHuabeiPay]: AliPayment, //花呗支付
  [PAY_WAY.AliPayCommand]: AliPayCommand, //吱口令支付
  [PAY_WAY.VirtualPay]: VirtualPayment, //印象笔记虚拟币支付
  [PAY_WAY.KSMiniProgramPay]: KSMiniProgramPayment, //快手小程序支付
  [PAY_WAY.MpBlankPay]: MiniProgramPayment, //店铺小程序、鹅圈子小程序、独立圈子小程序、视频号小程序、视频号分销小程序内嵌h5跳原生空白页支付
  [PAY_WAY.H5BlankPay]: H5BlankPayment, //非服务商模式、购物车下单支付跳空白页
  [PAY_WAY.ScanPay]: ScanPayment, //pc扫码支付，目前还不支持
};

export function getPaymentByType(type) {
  const Ctor = PAYMENT_MAP[type] || WxJSAPIPayment;
  return new Ctor();
}
